#include "chooselevel.h"
#include "ui_chooselevel.h"

ChooseLevel::ChooseLevel(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ChooseLevel)
{
    ui->setupUi(this);
    //传输信号，使按Back键返回主页面
    connect(ui->backButton,&QPushButton:: released,[=]()
    {
        emit closeWindow();
    });
    //从关卡页面打开游戏页面
    LevelBtn[0]=ui->levelButton1;
    LevelBtn[1]=ui->levelButton2;
    LevelBtn[2]=ui->levelButton3;
    LevelBtn[3]=ui->levelButton4;

    for(int i = 0; i<4; i++)
    {

        connect(LevelBtn[i],&QPushButton::clicked,[=]()
        {
            game_page=new GameWindow(i+1);
            game_page->show();
        });
    }
}

ChooseLevel::~ChooseLevel()
{
    delete ui;
}
